﻿Imports System.Windows.Forms

Public Class GrafiekAreaPin
    Inherits GrafiekAreaBase

    Public Overrides ReadOnly Property Type() As GrafiekAreaBase.GrafiekType
        Get
            Return GrafiekType.Pin
        End Get
    End Property

    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        MyBase.OnPaint(e)
        If (_data Is Nothing) Then Return
        Dim g As Graphics = e.Graphics
        Dim verticalSpan As Decimal = _data.MaxWaarde - _data.MinWaarde
        If (verticalSpan = 0D) Then verticalSpan = _data.MaxWaarde
        If (verticalSpan > 0D AndAlso _data.HorizontalSpan > 0D) Then
            For Each item As HistoriekDataSet.HistoriekRow In _data.DataTable
                Dim x As Integer = Convert.ToInt32(item.Datum.Subtract(_data.StartDatum).Days * Me.Width / _data.HorizontalSpan)
                Dim y As Integer = Convert.ToInt32(item.Waarde * Me.Height / verticalSpan)
                Dim color As Color = _data.GetColor(item.Naam)
                g.DrawLine(New Pen(color), x, Origin, x, Origin - y)
            Next
        End If
    End Sub

End Class
